package com.session01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ExceptionDemo {
    public static void main(String[] args) {
        //arrayDemo();
        ExceptionDemo ed = new ExceptionDemo();
        ed.testCheck();
    }

    public static void a() {
        a();
    }

    public static void b() {
        long[] array = new long[1024 * 1024 * 1024];
    }

    //数组越界异常
    public static void arrayDemo() {
        int[] arr = new int[]{1, 2, 3};
        try {
            for (int i = 0; i <= arr.length; i++) {
                System.out.print(arr[i] + " ");
            }
        } catch (Exception e) {
            System.out.println(e.getCause());
            System.out.println(e.getMessage());

        }
    }

    public void testCheck() {
        FileInputStream fis = null;
        String str = "";
        str = this.getClass().getResource("").getPath();
        try {
            fis = new FileInputStream(str + "1.txt");
        } catch (FileNotFoundException e1) {
            System.out.println("在e1");
        } catch (IOException e2) {
            System.out.println("在e2");
        } catch (Exception e3) {
            System.out.println("在e3");
        } finally {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (NullPointerException e1) {

            }
        }
        System.out.println("testCheck");
    }
}
